package com.fmc123.base.pesistence;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

import org.hibernate.annotations.GenericGenerator;

/**
 * 
* @ClassName: BaseEntity
* @Description: 实体基类 
* @author fmc
* @date 2015年9月13日下午5:07:41
*
 */
@MappedSuperclass
public class BaseEntity implements Serializable{

	private static final long serialVersionUID = 1L;
	/**作为标记的字段*/
    public static final String DEL_FLAG_FIELD="delFlag";
	/**删除标记*/
	public static final int DEL_FLAG_DELETE=1;
	/**正常标记*/
	public static final int DEL_FLAG_NORMAL=0;
	/**id字段*/
	public static final String ID="id";
	//主键id采用uuid生成
	@Id
	@Column(name = "id")
	@GenericGenerator(name = "idGenerator", strategy = "uuid")
	@GeneratedValue(generator = "idGenerator")
	private String id;
	
	/**
	 * 删除标记  0有效，1删除
	 */
	@Column(name = "DEL_FLAG" ,length = 1 ,nullable = false)  
	private int delFlag=DEL_FLAG_NORMAL;
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
    public int getDelFlag() {
      return delFlag;
    }
    public void setDelFlag(int delFlag) {
      this.delFlag = delFlag;
    }
    
    /**
     * 返回删除标记查询字符串，如delFlag='0'
     * @return
     */
    public String getQueryForDelFlag(){
      return DEL_FLAG_FIELD+" = '"+getDelFlag()+"'";
    }
}
